package net.fpeg.kotlin.msa.wordbase.entity

import javax.persistence.*

@Entity
@Table(name = "word_user")
data class WordUser(
        @Id
        val id: Long,

        @OneToMany(mappedBy = "wordUser")
        val wordBases: Set<WordBase>,

        @OneToMany(mappedBy = "wordUser")
        val wordTags: Set<WordTag>,

        @OneToMany(mappedBy = "wordUser")
        val wordSources: Set<WordSource>,


        @OneToMany(mappedBy = "wordUser")
        val wordNotes: Set<WordNote>,

        @OneToMany(mappedBy = "wordUser")
        val wordUserRelationTypes: Set<WordUserRelationType>,

        @OneToOne(cascade = [CascadeType.ALL])
        @JoinColumn(name = "default_word_source_id")
        var defaultSource: WordSource? = null,

        @OneToOne
        @JoinColumn(name = "default_tag_id")
        var defaultTag: WordTag? = null,

        @OneToOne
        @JoinColumn(name = "default_relation_type_id")
        var defaultRelationType: WordUserRelationType? = null

){
        override fun hashCode(): Int = id.toInt()
}